package de.tayrracer;

public class Math {
	public static double scalarProduct(double[] x, double[] y){
		return x[0]*y[0]+x[1]*y[1]+x[2]*y[2];
	}
	
	public static double[] scalarMult(double x, double[] y){
		return new double[] {x*y[0],x*y[1],x*y[2]};
	}
	
	public static double[] crossProduct(double[] x, double[] y){
		return new double[] {x[1]*y[2]-x[2]*y[1],x[2]*y[0]-x[0]*y[2],x[0]*y[1]-x[1]*y[0]};
	}
	
	public static double[] addVectors(double[] x, double[] y){
		return new double[] {x[0]+y[0],x[1]+y[1],x[2]+y[2]};
	}
	
	public static double[] subtractVectors(double[] x, double[] y){
		return new double[] {x[0]-y[0],x[1]-y[1],x[2]-y[2]};
	}
	
	public static double distance(double[] x, double[] y){
		double[] difference = subtractVectors(x,y);
		return java.lang.Math.sqrt(scalarProduct(difference,difference));
	}
}
